from datetime import datetime
from typing import Optional
from pydantic import BaseModel

class AdvertisementBase(BaseModel):
    title: str
    content: str
    image_url: Optional[str] = None
    target_url: str
    budget: float
    start_time: datetime
    end_time: datetime

class AdvertisementCreate(AdvertisementBase):
    advertiser_id: str

class AdvertisementUpdate(BaseModel):
    title: Optional[str] = None
    content: Optional[str] = None
    image_url: Optional[str] = None
    target_url: Optional[str] = None
    budget: Optional[float] = None
    start_time: Optional[datetime] = None
    end_time: Optional[datetime] = None

class Advertisement(AdvertisementBase):
    id: str
    advertiser_id: str
    created_at: datetime
    click_count: int = 0
    impression_count: int = 0